﻿namespace ScrumLite.WebUx.Tests
{
    using System;
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    using ScrumLite.Services;
    using ScrumLite.Services.Contracts;

    public class MockProfileService : IProfileService
    {
        public bool GetPeopleCalled { get; set; }
        public bool GetFullNameCalled  { get; set; }
        public bool GetUserRolesCalled { get; set; }

        private static List<Person> people;

        public MockProfileService()
        {
            people = new List<Person>();
            people.Add(new Person { Id = "jpgarcia@corpnet.ad", Name = "Juan Pablo García" });
            people.Add(new Person { Id = "mwoloski@corpnet.ad", Name = "Matias Woloski" });
            people.Add(new Person { Id = "jarguello@corpnet.ad", Name = "Juan Arguello" });
            people.Add(new Person { Id = "alopez@corpnet.ad", Name = "Angel Java Lopez" });
            people.Add(new Person { Id = "ldamiani@corpnet.ad", Name = "Lito Damiani" });
        }

        public string GetFullName(string samAccountName)
        {
            GetFullNameCalled = true;
            return samAccountName;
        }

        public string[] GetUserRoles(string samAccountName)
        {
            this.GetUserRolesCalled = true;
            List<string> roles = null;

            if (samAccountName != "UnExistingUser")
            {
                roles.Add("role1");
                roles.Add("role2");
            }

            return roles.ToArray();
        }

        public bool IsUserInRole(string samAccountName, string role)
        {
            return true;
        }

        public Collection<Person> GetPeople()
        {
            GetPeopleCalled = true;
            return new Collection<Person>(people);
        }
    }
}
